// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use clap::{Parser, ValueHint};
use tauri::Manager;

#[derive(Parser)]
#[clap(version = env!("CARGO_PKG_VERSION"))]
struct Opts {
    /// Input CSV fil, stdin if not present.
    #[clap(name = "URL", value_parser, value_hint = ValueHint::Url)]
    url: String,
}

fn main() {
    tauri::Builder::default()
        .setup(|app| {
            let opts: Opts = Opts::parse();
            let window = app.get_window("main").unwrap();
            window.eval(&format!("window.location = '{}';", opts.url))?;
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
